#include <vector>
class Solution {
public:
    vector<double> nums;
    priority_queue<int> q;
    priority_queue<int> tmp;

    void Insert(int num) {
        q.push(num);
    }

    double GetMedian() { 
        double res;
        tmp = q;
        nums.clear();
        while (!tmp.empty()) {
            nums.push_back(tmp.top());
            tmp.pop();
        }
        int n = nums.size();
        if (n % 2 == 0) {
            res = (nums[n/2] + nums[n/2-1]) / 2;
        } else {
            res = nums[n/2];
        }
        return res;
    }

};